//修改已有分类的名称

import React, { useEffect, useRef } from 'react';
import { Form, Input } from 'antd';
import PropTypes from 'prop-types';

const UpdateForm = ({ setForm, categoryName }) => {
  const [form] = Form.useForm();
  const formRef = useRef(form);

  useEffect(() => {
    setForm(formRef.current);
  }, [setForm]);

  return (
    <Form form={form} layout="vertical">
      <Form.Item
        label="分类名称"
        name="categoryName"
        initialValue={categoryName}
        rules={[{ required: true, message: '请输入分类名称' }]}
      >
        <Input placeholder="请输入分类名称" />
      </Form.Item>
    </Form>
  );
};

UpdateForm.propTypes = {
  setForm: PropTypes.func.isRequired,
  categoryName: PropTypes.string.isRequired,
};

export default UpdateForm;